package web;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by cww
 * Date : 2018/5/11
 */
public class TestBeanName implements BeanNameAware,ApplicationContextAware{

    private String beanName;
    @Override
    public void setBeanName(String s) {
        this.beanName = s;
        System.out.println("传入的Bean "+ s);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println(applicationContext.getBean(this.beanName));
    }
}
